package com.lc.admin.interceptor;

import com.alibaba.fastjson.JSONObject;
import com.lc.admin.base.ResponseResult;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class OtherException40xHandler implements AccessDeniedHandler {
    @Override
    public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException {
        System.out.println("-----------------------------------------------发现异常..." + response.getStatus());
        ResponseResult result = ResponseResult.error("权限不足");
        String json = JSONObject.toJSONString(result);
        response.getWriter().write(json);
    }
}
